package org.idea.spring.bean.alias;

import org.idea.spring.bean.beandefinitionbuilder.User;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @Author idea
 * @Date created in 8:24 上午 2020/6/29
 */
public class BeanAliasDemo {

    public static void main(String[] args) {
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("alias-bean.xml");
        User femaleUser = (User) applicationContext.getBean("f-user");
        System.out.println(femaleUser.toString());
        User maleUser = (User) applicationContext.getBean("m-user");
        System.out.println(maleUser.toString());

        User maleUserOrg  = (User) applicationContext.getBean("maleUser");
        User femaleUserOrg = (User) applicationContext.getBean("femaleUser");
        System.out.println(" maleUserOrg == maleUser :" + ( maleUser == maleUserOrg ));
    }
}
